package ru.artyushov.fingers.core;

import ru.artyushov.fingers.core.basic.LightnessBasedBinarizer;
import ru.artyushov.fingers.core.basic.SpecialPointsExtractor;
import ru.artyushov.fingers.core.basic.SpecialPointsFeatureSet;
import ru.artyushov.fingers.core.data.Fingerprint;
import ru.artyushov.fingers.core.io.FingerprintReaderImpl;
import ru.artyushov.fingers.core.preprocessor.PatternBasedSkeletizer;
import ru.artyushov.fingers.core.preprocessor.SpuriousForkRemover;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * User: nikart
 * Date: 12.05.12
 */
public class MainClass {

    private static final String firstImage = "/Users/nikart/Desktop/test1.png";
    private static final String secondImage = "/Users/nikart/Desktop/test2.png";

    private static final List<Preprocessor> preprocessors = new ArrayList<Preprocessor>();

    static {
        preprocessors.add(new PatternBasedSkeletizer());
        preprocessors.add(new SpuriousForkRemover(10));
    }

    public static void main(String[] args) throws IOException {
        FingerprintReaderImpl fingerprintReader = new FingerprintReaderImpl(new LightnessBasedBinarizer());
        Fingerprint first = fingerprintReader.readFrom(new FileInputStream(firstImage));
        Fingerprint second = fingerprintReader.readFrom(new FileInputStream(secondImage));

        for (final Preprocessor preprocessor : preprocessors) {
            first = preprocessor.workYourMagic(first);
            second = preprocessor.workYourMagic(second);
        }

        SpecialPointsExtractor extractor = new SpecialPointsExtractor();
        SpecialPointsFeatureSet firstFeatures = extractor.extractFeatures(first);
        SpecialPointsFeatureSet secondFeatures = extractor.extractFeatures(second);

        System.out.println(firstFeatures.getMatchProbability(secondFeatures));
    }
}
